<%--
  Created by IntelliJ IDEA.
  User: kkk
  Date: 2022/10/7
  Time: 17:08
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>修改信息</title>
    <script src="js/jquery.js"></script>
    <base href="${pageContext.request.contextPath}/">
</head>
<body>

<form action="PowerUpdateServlet" method="get">
    <table border="1">
        <h1>新能源汽车电池信息</h1>
        <tr>
            <td>车辆类型：</td>
            <td><input type="text" name="carName" id="carName" value="${sessionScope.power.carName}"></td>
        </tr>
        <tr>
            <td>所属城市：</td>
            <td><input type="text" name="cityName" id="cityName" value="${sessionScope.power.cityName}"></td>
        </tr>
        <tr>
            <td>使用单位：</td>
            <td><input type="text" name="userName" id="userName" value="${sessionScope.power.userName}"></td>
        </tr>
        <tr>
            <td>压差报警器：</td>
            <td><input type="text" name="pressureValue" id="pressureValue" value="${sessionScope.power.pressureValue}"></td>
        </tr>
        <tr>
            <td>报警时间：</td>
            <td><input type="text" name="time" id="time" value="${sessionScope.power.time}"></td>
        </tr>
        <tr>
            <td>操作：</td>
            <td><input type="submit" value="修改"></td>
        </tr>
    </table>
</form>
</body>
<script>
    $('form').submit(function (){
        var teg=/^\d{4}-\d{2}-\d{2}$/;
        if ($('#carName').val()==="" || $('#cityName').val()==="" || $('#userName').val()==="" || $('#pressureValue').val()==="" || $('#time').val()===""){
            alert("请填写完整的信息！");
            return false;
        }
        else if (isNaN($('#pressureValue').val())){
            alert("压差报警器必须是数值类型！");
            return false;
        }else if(!teg.test($('#time').val())){
            alert("时间格式不合法。正确格式是yyyy-MM-dd！");
            return false;
        }
    })
</script>
</html>
